Skip to main content

Introduction

React to everything the SDK does—without modifying the SDK itself.

The EventHandlers object is a collection of callback functions that the Mobile SDK invokes whenever something noteworthy happens: a new push‑notification arrives, a credential is issued, a proof response is sent, and so on. By implementing these callbacks you can:

  • update local state or Redux stores,
  • show toast banners or system notifications,
  • navigate the user to a specific screen,
  • fire analytics events, or
  • trigger follow‑up API calls.
Note

EventHandlers do not render any UI and they do not return values to the SDK. They are pure side‑effect hooks—your app is responsible for deciding what each event means and how to present it. The examples below demonstrate one possible implementation; adapt them to your architecture.


Wiring it up

app/agentConfig.ts
const eventHandlers: EventHandlers = {
// we’ll fill these in on the dedicated pages
};

export const agentConfig: AgentConfig = {
encryptionKey: DB_ENCRYPTION_KEY,
home: agentInfo,
webSocketSettings: {
idleTimeoutSeconds: 180,
scanIntervalSeconds: 5,
},
autoProcessIncomingMessages: false,
userInfo: {
name: `${firstName} ${lastName}`,
},
callbackHandlers,
activityCallbackHandlers,
eventHandlers, // ← plug them in here
};

Once the agent is initialised, the SDK begins emitting events, and your handlers run on whichever thread the JS bridge is on. Ensure any heavy work (database writes, network calls) is awaited or off‑loaded as needed.


Minimal scaffold

useEventHandlers.ts
import { useMemo } from 'react';
import {
EventHandlers,
Credential,
TrackEventMessage,
} from '@one37id/mobile-js-sdk';
import { eventEmitter } from '../services';

export const useEventHandlers = (): EventHandlers =>
useMemo(
() => ({
onNotificationAdded: async (model) => {
console.debug('Notification added', model);
eventEmitter.emit('notificationAdded', model);
},
// …other handlers go here…
onException: async (err) => {
console.error('SDK Exception', err);
},
}),
[],
);

Attach this hook during app start‑up; the returned object can be fed straight into AgentConfig.


Event catalogue

Each event has its own page with payload shape, common use‑cases, and code snippets:

Next sections dive into each event one by one.

X

Graph View